home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / dvglue10.arc / TVKREAD.C < prev    next >
C/C++ Source or Header  |  1988-08-13  |  1KB  |  40 lines

  1. /*================================================*/
  2. /* TVKREAD.C                                      */
  3. /*                                                */
  4. /* (c) Copyright 1988 Ralf Brown                  */
  5. /*     All Rights Reserved                        */
  6. /* May be freely copied for noncommercial use,    */
  7. /* provided that this copyright notice remains    */
  8. /* intact and any changes are indicated in the    */
  9. /* comment blocks preceding functions             */
  10. /*================================================*/
  11.  
  12. #include <stdio.h>
  13. #include "tvapi.h"
  14.  
  15. /*================================================*/
  16. /* TVkbd_read   get input from keyboard           */
  17. /*   Ralf Brown 4/22/88                           */
  18. /*================================================*/
  19.  
  20. int pascal TVkbd_read(OBJECT kbd,char *buffer,int maxsize)
  21. {
  22.    PARMLIST2 p ;
  23.    int count ;
  24.  
  25.    if (buffer == NULL)
  26.       return 0 ;
  27.    p.num_args = 0 ;
  28.    TVsendmsg(READ_MSG, kbd?TOS:KEYME, kbd, (PARMLIST *)&p) ;
  29.    count = (int) p.arg[1] ;
  30.    maxsize-- ;  /* reserve space for the null to terminate the string */
  31.    if (count > maxsize)
  32.       count = maxsize ;
  33.    while (count-- > 0)
  34.       *buffer++ = *((char far *)p.arg[0])++ ;
  35.    *buffer = '\0' ;
  36.    return (int) p.arg[1] ;
  37. }
  38.  
  39. /* End of TVKREAD.C */
  40.